package com.longcai.piaojia.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/10/31.
 */
@HttpInlet(Conn.ORDER_INDEX_SCREENINGS)
public class ChooseGoodsNumListGet extends BaseAsyGet<ChooseGoodsNumListGet.ChooseGoodsNumListEntity> {

    public String id;

    public ChooseGoodsNumListGet(AsyCallBack<ChooseGoodsNumListEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected ChooseGoodsNumListEntity parser(JSONObject object) throws Exception {

        if(object.optInt("code")==200){

            JSONArray array = object.optJSONArray("data");

            ChooseGoodsNumListEntity chooseGoodsNumListEntity = new ChooseGoodsNumListEntity();

            for (int i = 0; i < array.length(); i++) {

                JSONObject objectPriceEntity = array.optJSONObject(i);

                NumEntity numEntity = new NumEntity();

                numEntity.id = objectPriceEntity.optString("id");
                numEntity.times = objectPriceEntity.optString("times");
                numEntity.title = objectPriceEntity.optString("title");
                numEntity.product_id = objectPriceEntity.optString("product_id");

                chooseGoodsNumListEntity.NubEntityList.add(numEntity);

            }

            return chooseGoodsNumListEntity;

        }

        TOAST = object.optString("message");

        return null;
    }

    public static class ChooseGoodsNumListEntity {

        public List<NumEntity> NubEntityList = new ArrayList<>();
    }

    public static class NumEntity {

        public String id, title, times, product_id;

    }

}
